<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!-- 引入主题样式 -->
<link
	href="${pageContext.request.contextPath }/themes/bootstrap/easyui.css"
	rel="stylesheet">
<!-- 引入图标的样式 -->
<link href="${pageContext.request.contextPath }/themes/icon.css"
	rel="stylesheet">
<!-- 先引入jquery -->
<script type="text/javascript"
	src="${pageContext.request.contextPath }/js/jquery-1.7.2.js"></script>
<!-- 引入easyui.js -->
<script type="text/javascript"
	src="${pageContext.request.contextPath }/js/jquery.easyui.min.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath }/js/easyui-lang-zh_CN.js"></script>
</head>
<script type="text/javascript">
$(function(){
	var ws = null;
	if ('WebSocket' in window) {
		ws = new WebSocket("ws://172.18.23.232:8080/System4/socket");
	} else {
		alert('当前浏览器 Not support websocket')
	}
	ws.onopen = function(){
		
	}
	ws.onclose = function(){
		
	}
	ws.onmessage = function(event){
		
	}
	ws.onerror = function(){
		
	}
	window.onbeforeunload = function () {
        ws.close();
    }
	
	$('#tb').textbox({    
		multiline:true,
		height:100,
		width:400,
		prompt:'消息通知..........',
	})
	
	$('#btn').linkbutton({    
	    iconCls: 'icon-ok',
	    onClick:function(){
	    	var msg = $('#tb').textbox('getText');
	    	if(msg!=null){
	    		ws.send(msg);
		    	$('#tb').textbox('setText','');
	    	}	
	    }
	});  
	
})
</script>

<body>
	  <input id="tb" type="text" style="width:300px">
	  <a id="btn" href="#">发送</a> 
	  <div id="message"></div>
</body>
</html>